using System;
using System.Collections.Generic;
using System.Text;
using SdlDotNet.Graphics.Sprites;
using System.Drawing;
using SnakeCharp.Entity;
using SdlDotNet.Graphics;

namespace SnakeCharp.UI
{
    public class GameHud : Sprite
    {
        //UIFonts
        private UIFont scoreFont;

        //Game variables
        private int score = 0;
        private Color backgroundColor;

       
        //List of GuiElements
        private List<UIFont> guiCollection;

        public GameHud()
            : base(new Surface(200, 75, Configurations.BitsPerPixel, true))
        {
            //Setup GameHud
            this.X = Configurations.ScreenWidth - this.Width;
            this.Y = Configurations.ScreenHeight - 80;
            this.Transparent = true;
            this.TransparentColor = Color.Black;
            //backgroundColor = Color.White;

            //Setup the individuel objects for the GameHud
            scoreFont = new UIFont("Score: ", 24);
            scoreFont.Position = new Point(20, 35);
            scoreFont.Color = Color.GreenYellow;

            //Add to the collection being Blit's to the DebugHUD Surface
            guiCollection = new List<UIFont>();
            guiCollection.Add(scoreFont);
        }

        /// <summary>
        /// Updates this instance.
        /// </summary>
        public void Update()
        {
            //Blit all components to the DebugHUD
            scoreFont.Text = "Score: " + score;            
        }

        /// <summary>
        /// Renders this instance.
        /// </summary>
        /// <returns></returns>
        public void Render(Surface destination)
        {
            //Clear the DebugHUD Surface
            this.Surface.Fill(backgroundColor);

            //Blit all to the DebugHUD Surface
            foreach (UIFont ui in guiCollection)
            {
                this.Surface.Blit(ui);
            }

            destination.Blit(this.Surface, this.Rectangle);
        }


        #region Properties

        /// <summary>
        /// Gets or sets the score.
        /// </summary>
        /// <value>The score.</value>
        public int Score
        {
            get { return score; }
            set { score = value; }
        }

        #endregion
    }
}
